package config

import "strconv"

type Mysql struct {
	Host     string `mapstructure:"host"`      // `yaml:"host"`
	Port     int    `mapstructure:"port"`      // `yaml:"port"`
	Config   string `mapstructure:"config"`    // `yaml:"config"` // 高级配置,例如charset
	DB       string `mapstructure:"db"`        // `yaml:"db"`
	User     string `mapstructure:"user"`      // `yaml:"user"`
	Password string `mapstructure:"password"`  // `yaml:"password"`
	LogLevel string `mapstructure:"log_level"` // `yaml:"log_level"` // 日志登记 debug就是输出全部sql,dev,release
}

func (this Mysql) Dsn() string {
	return this.User + ":" + this.Password + "@tcp(" + this.Host + ":" + strconv.Itoa(this.Port) + ")/" + this.DB + "?" + this.Config
}
